<ui:composition template="/WEB-INF/templates/template-principal.xhtml" xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets">

	<ui:define name="conteudo">
		<h:form>
			<h:dataTable rendered="${not empty departamentoBean.departamentos}" value="#{departamentoBean.departamentos}" var="dep"
				styleClass="tabela">
				<f:facet name="header">Departamentos</f:facet>

				<h:column>
					<f:facet name="header">Código</f:facet>
					#{dep.id}
				</h:column>

				<h:column>
					<f:facet name="header">Nome</f:facet>
					#{dep.nome}
				</h:column>

				<h:column>
					<f:facet name="header">Quant. Funcionários</f:facet>
					<h:commandLink value="#{dep.funcionarios.size()}" action="#{departamentoBean.listaFuncionarios()}">
						<f:param name="idDepartamento" value="#{dep.id}" />
					</h:commandLink>
				</h:column>

				<h:column>
					<f:facet name="header">Opções</f:facet>
					<h:panelGroup>
						<h:commandLink value="Alterar" action="#{departamentoBean.preparaAlteracao()}">
							<f:param name="idDepartamento" value="#{dep.id}" />
						</h:commandLink>
						-
						<h:commandLink value="Remover" action="#{departamentoBean.remove()}">
							<f:param name="idDepartamento" value="#{dep.id}"></f:param>
						</h:commandLink>
					</h:panelGroup>
				</h:column>
			</h:dataTable>
		</h:form>

		<h:panelGroup rendered="${empty departamentoBean.departamentos}">
			<h1>Não há departamentos.</h1>
		</h:panelGroup>

	</ui:define>
</ui:composition>
